package com.chen.controller;

import com.chen.domain.User;
import com.chen.dto.R;
import com.chen.model.LoginUser;
import com.chen.service.UserLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.bind.ValidationException;

/**
 * @Author: chen
 * @Date: 2021/4/27 10:13 AM
 * @Version 1.0
 */
@RestController
@Api(tags = "用户登录接口")
public class UserLoginController {

    @Autowired
    private UserLoginService userLoginService;

    @PostMapping("/login")
    @ApiOperation(value = "会员的登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "loginForm", value = "登录的表单参数")
    })
    public R<LoginUser> login(@RequestBody User loginForm) throws ValidationException {
        LoginUser loginUser = userLoginService.login(loginForm);
        return R.ok(loginUser);
    }

}
